<template>
	<div class="wrap" v-loading="loading" element-loading-text="等下,我正在请求" element-loading-spinner="el-icon-loading">
		<basic-opt :has_left="true">
			<template #search>
				<div class="opt-item">
					<el-input class="w-ipt" placeholder="请输入地址名进行筛选" suffix-icon="el-icon-search"
						v-model="search.address" @keydown.enter="getSearchData" size="medium">
					</el-input>
				</div>
				<!-- <div class="u-opt-item">
          <el-cascader class="w-ipt" v-model="pro_city_area" placeholder="请选择省市区" :options="cascaderData"
            @change="handleSearch" :props="props" :show-all-levels="false"></el-cascader>
        </div> -->
				<div class="opt-item">
					<el-button @click="getSearchData" size="medium">搜索</el-button>
				</div>
				<div class="opt-item">
					<reset-search></reset-search>
				</div>
			</template>
			<template #add>
				<div class="opt-item">
					<el-button @click="addForm" icon="el-icon-circle-plus-outline" type="primary" size="medium">添加地址
					</el-button>
				</div>
			</template>
		</basic-opt>

		<div class="table-box">
			<el-table :data="data" stripe :header-cell-style="header_cell_style" :max-height="table_max_height">
				<el-table-column prop="id" label="ID"></el-table-column>
				<el-table-column prop="address" label="地址" width="400px"></el-table-column>
				<el-table-column prop="area.title" label="所在地区"></el-table-column>
				<el-table-column prop="contact" label="联系方式" width="400px"></el-table-column>
				<el-table-column prop="address_uuid" label="address_uuid" width="200px"></el-table-column>
				<el-table-column fixed="right" label="操作" width="460px">
					<template #default="scope">
						<el-dropdown trigger="click">
							<el-button size="mini" type="success">
								编辑<i class="el-icon-arrow-down el-icon--right"></i>
							</el-button>
							<template #dropdown>
								<el-dropdown-menu>
									<el-dropdown-item>
										<el-button type="text" @click="onAddressInfo(scope.row.id)">编辑地址信息</el-button>
									</el-dropdown-item>
									<el-dropdown-item>
										<el-button type="text" @click="onAddressCode(scope.row.id)">编辑地址编码</el-button>
									</el-dropdown-item>
									<el-dropdown-item>
										<el-button type="text" @click="onAddressFaceGroup(scope.row.id)">编辑人脸库
										</el-button>
									</el-dropdown-item>
									<el-dropdown-item>
										<el-button type="text" @click="onAddressStation(scope.row.id)">编辑录入辖区
										</el-button>
									</el-dropdown-item>
									<el-dropdown-item v-if="scope.row.notify_repair == '1' ">
										<el-button type="text" @click="onAddressMaintenance(scope.row.id)">编辑录入维护人员
										</el-button>
									</el-dropdown-item>
								</el-dropdown-menu>
							</template>
						</el-dropdown>
						<el-button @click="onRoomManage(scope.row)" type="info" plain size="mini">房间管理</el-button>
						<el-button @click="onDelData(scope.row)" type="danger" plain size="mini">删除</el-button>
						<el-button @click="onInfoDetail(scope.row)" type="info" plain size="mini">信息详情</el-button>
					</template>
				</el-table-column>
			</el-table>
		</div>

		<page-component @pageChanged="onPageChanged"></page-component>

		<!-- 添加地址 -->
		<compoment-drawer :drawer_name="drawer_name" :drawer_form="drawer_form" @getDrawerForm="getDrawerForm">
			<el-scrollbar height="90vh" v-loading="form_loading" element-loading-text="正在进行请求,请稍后"
				element-loading-spinner="el-icon-loading">
				<el-tabs v-model="tabActive" tab-position="left" @tab-click="tabActiveChange">
					<el-tab-pane label="填写地址信息" name="1">
						<el-form ref="form" :model="form" label-position="top">
							<el-row :gutter="20">
								<el-col :span="8">
									<el-form-item label="选择项目" prop="project_id">
										<project-component :project_id="form.project_id" @getProjectId="getProjectId">
										</project-component>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="选择百度接口" prop="aip_id">
										<baidu-interface :aip_id="form.aip_id" @getBaiduAipId="getBaiduAipId">
										</baidu-interface>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="选择类型" prop="type">
										<el-select class="w-ipt" v-model="form.type" placeholder="请选择类型">
											<el-option v-for="(value, name) in type_list" :label="value" :value="name"
												:key="name">
											</el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="联系方式" prop="contact">
										<el-input class="w-ipt" v-model="form.contact" placeholder="请填写联系方式">
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="是否通知维护人员" prop="notify_repair">
										<el-radio-group v-model="form.notify_repair" @change="maintenanceChange">
											<el-radio :label="1">通知</el-radio>
											<el-radio :label="2">不通知</el-radio>
										</el-radio-group>
									</el-form-item>
								</el-col>
								<el-col :span="24">
									<el-form-item label="选择社区" prop="area_id">
										<area-component :area_id="form.area_id" @getAreaId="getAreaId">
										</area-component>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="请填写地址" prop="address">
										<el-input type="textarea" v-model="form.address" placeholder="请填写地址">
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="经度显示" prop="lng">
										<el-input v-model="form.lng" placeholder="经度显示">
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="纬度显示" prop="lat">
										<el-input v-model="form.lat" placeholder="纬度显示">
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="24">
									<el-form-item label="请点击地图选择对应地址的经纬度">
										<el-switch v-model="on_map" active-text="打开地图" active-color="#2a9f93">
										</el-switch>
										<div v-if="on_map">
											<v-map @getLoc="getLoc"></v-map>
										</div>
									</el-form-item>
								</el-col>
							</el-row>
							<submit-reset v-if="tabActive == 1" @getChildNewForm="getNewForm"
								@getChildResetForm="initAddressInfo('form')">
							</submit-reset>
						</el-form>
					</el-tab-pane>
					<el-tab-pane label="录入地址编码" name="2">
						<el-form v-if="form.id" ref="address_code_form" :model="address_code_form" label-position="top">
							<el-row :gutter="20">
								<el-col :span="24">
									<el-form-item label="地址编码">
										<address-code ref="childCode" @getCode="getOrderCode"
											:dataCode="address_code_form.info">
										</address-code>
									</el-form-item>
								</el-col>
							</el-row>
							<submit-reset v-if="tabActive == 2" @getChildNewForm="getNewForm"
								@getChildResetForm="initAddressCode('address_code_form')">
							</submit-reset>
						</el-form>
					</el-tab-pane>
					<el-tab-pane label="录入人脸库" name="3">
						<el-form v-if="form.id" ref="face_group_form" :model="face_group_form" label-position="top">
							<el-form-item label="人脸分组操作">
								<el-button size="mini" type="primary" @click="addFace">添加人脸姓名
								</el-button>
								<el-button size="mini" type="danger" @click="delFace">删除人脸姓名</el-button>
							</el-form-item>
							<el-row :gutter="20" v-for="(item,index) in face_group_form.groups" :key="index">
								<el-col :span="8">
									<el-form-item label="人脸分组姓名">
										<el-input type="textarea" v-model="item.group_name" placeholder="请填写人脸分组姓名">
										</el-input>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="是否默认分组">
										<el-radio-group v-model="item.is_default">
											<el-radio :label="1">是</el-radio>
											<el-radio :label="2">否</el-radio>
										</el-radio-group>
									</el-form-item>
								</el-col>
								<el-col :span="8">
									<el-form-item label="是否为在线分组">
										<el-radio-group v-model="item.online">
											<el-radio :label="1">是</el-radio>
											<el-radio :label="2">否</el-radio>
										</el-radio-group>
									</el-form-item>
								</el-col>
							</el-row>
							<submit-reset v-if="tabActive == 3" @getChildNewForm="getNewForm"
								@getChildResetForm="initAddressFaceGroup('face_group_form')">
							</submit-reset>
						</el-form>
					</el-tab-pane>
					<el-tab-pane label="录入辖区" name="4">
						<el-form v-if="form.id" ref="station_form" :model="station_form" label-position="top">
							<el-row :gutter="20">
								<el-col :span="24">
									<el-form-item label="选择公安辖区" prop="stations">
										<station-component v-if="tabActive == '4' " :station_id="station_form.stations"
											@getStationId="getStationId"></station-component>
									</el-form-item>
								</el-col>
							</el-row>
							<submit-reset v-if="tabActive == 4" @getChildNewForm="getNewForm"
								@getChildResetForm="initAddressStation('station_form')">
							</submit-reset>
						</el-form>
					</el-tab-pane>
					<el-tab-pane label="录入维护人员" name="5" v-if="form.id && form.notify_repair == 1">
						<el-form ref="maintenance_form" :model="maintenance_form" label-position="top">
							<el-row :gutter="20">
								<el-col :span="24">
									<el-form-item label="选择维护人员">
										<maintenance-component v-if="form.notify_repair == 1"
											:maintenance="new_repairers" ref="refMaintenanceComponent"
											@getMaintenance="getMaintenance">
										</maintenance-component>
									</el-form-item>
								</el-col>
							</el-row>
							<submit-reset v-if="tabActive == 5" @getChildNewForm="getNewForm"
								@getChildResetForm="initAddressMaintenance('maintenance_form')">
							</submit-reset>
						</el-form>
					</el-tab-pane>
				</el-tabs>
			</el-scrollbar>
		</compoment-drawer>

		<!-- 删除数据确认 -->
		<delete-data :del_data_dialog="del_data_dialog" @getDelData="getDelData" @getCancelDelData="getCancelDelData">
			<el-descriptions class="margin-top" :column="1" size="medium" border>
				<el-descriptions-item>
					<template #label>
						id
					</template>
					{{ delData.id }}
				</el-descriptions-item>
				<el-descriptions-item>
					<template #label>
						地址
					</template>
					{{ delData.address }}
				</el-descriptions-item>
				<el-descriptions-item>
					<template #label>
						所在地区
					</template>
					{{ delData.area ? delData.area.title : '' }}
				</el-descriptions-item>
				<el-descriptions-item>
					<template #label>
						联系方式
					</template>
					{{ delData.contact }}
				</el-descriptions-item>
			</el-descriptions>
		</delete-data>
	</div>
	<!--  mobile  -->
	<div class="mobile-wrap" v-loading="loading" element-loading-text="等下,我正在请求"
		element-loading-spinner="el-icon-loading">
		<div class="mobile-search-box">
			<el-input class="w-ipt" placeholder="请输入地址名进行筛选" suffix-icon="el-icon-search" v-model="search.address"
				@keydown.enter="getSearchData" size="medium">
			</el-input>
			<el-button @click="getSearchData" size="medium">搜索</el-button>
		</div>
		<div class="moblie-table-box">
			<el-table :data="data" stripe :header-cell-style="header_cell_style" :max-height="mobile_table_max_height">
				<el-table-column prop="id" label="ID"></el-table-column>
				<el-table-column prop="address" label="地址" width="400px"></el-table-column>
				<el-table-column prop="area.title" label="所在地区"></el-table-column>
				<el-table-column prop="contact" label="联系方式" width="400px"></el-table-column>
				<el-table-column prop="address_uuid" label="address_uuid" width="200px"></el-table-column>
				<el-table-column label="操作" width="200px">
					<template #default="scope">
						<el-button @click="onRoomManage(scope.row)" type="info" plain size="mini">房间管理</el-button>
						<el-button @click="onInfoDetail(scope.row)" type="info" plain size="mini">信息详情</el-button>
					</template>
				</el-table-column>
			</el-table>
		</div>
		<page-component @pageChanged="onPageChanged"></page-component>
	</div>
</template>

<script>
	import API from '@/api/index.js'
	import vMap from '@/components/map/map-iframe.vue'
	import BaiduInterface from '@/components/form/baidu-interface.vue'
	import ProjectComponent from '@/components/form/project-component.vue'
	import AddressCode from '@/components/form/address/address-code.vue'
	import AreaComponent from '@/components/form/area-component.vue'
	import StationComponent from '@/components/form/address/station-component.vue'
	import MaintenanceComponent from '@/components/form/address/maintenance-component.vue'
	import mixin from '@/mixin.js'

	export default {
		name: 'address-list',
		mixins: [mixin],
		components: {
			vMap,
			BaiduInterface,
			ProjectComponent,
			AddressCode,
			AreaComponent,
			StationComponent,
			MaintenanceComponent
		},
		data() {
			return {
				confirmAddressData: false,
				search: { // 搜索
					address: '',
					search_area_id: []
				},
				pro_city_area: [], // 根据省市区搜索
				cascaderData: [],
				props: {
					label: 'title',
					value: 'id',
					checkStrictly: true,
				},

				// 表单
				edit_model: false,
				drawer_name: '添加地址',
				tabActive: "1",
				form_loading: false, // 表单填写时加载
				form: {
					id: '',
					project_id: '',
					aip_id: '',
					type: '',
					area_id: '0',
					contact: '',
					address: '',
					lng: '',
					lat: '',
					bind: '1',
					notify_repair: 2
				},

				address_code_form: { // 地址编码
					address_id: '',
					info: [],
				},

				face_group_form: { // 人脸组
					address_id: '',
					groups: [],
				},

				station_form: { // 辖区
					address_id: '',
					stations: [],
				},

				maintenance_form: { // 维护人员
					address_id: '',
					repairers: []
				},
				new_repairers: [],

				order_value: {}, // 地址编码之类的值
				type_list: [], // 获取设备类型
				on_map: false,
			}
		},
		mounted() {
			this.getData();
			// this.getProArae(); // 省市区数据
			this.getAddressType();
		},
		methods: {
			async getData() {
				let self = this;
				self.loading = true;
				try {
					let params = {
						format: 1,
						area_id: [],
						search: self.search.address,
					}
					self.addPageInfo(params)
					let res = await API.addresses(params.pageNumber, params.pageSize, params.format, params.area_id,
						params.project_id, params.search)
					self.loading = false;
					self.onGotPageData(res)
				} catch (err) {
					self.loading = false;
				}
			},

			// 获取社区列表（省市区选中）
			getProArae() {
				let self = this;
				API.areas(1, 100, 0).then(res => {
					self.cascaderData = res.data.data;
				})
			},
			// 获取地址
			areaProChange(val) {
				let self = this;
				console.log(val)
				self.search_area_id = [];
				self.search_area_id.push(val[val.length - 1]);
				self.loading = true;
				API.addresses(1, 10, 1, self.search_area_id, '', self.searchAddress).then(res => {
					let data = res.data.data;
					self.$message.success("获取地址数据成功");
					self.loading = false;
					self.addressData = data.data;
					self.total = data.total;
					self.current = 1;
				}).catch(err => {
					self.loading = false;
					self.$message.error(err.response.data.message)
				})
			},
			// 搜索地址
			handleSearch(val) {
				let self = this;
				self.search.search_area_id = val[val.length - 1];
				self.loading = true;
				API.addresses(1, 10, 1, self.search.search_area_id, '', self.search.address).then(res => {
					let data = res.data.data;
					self.$message.success("获取地址数据成功");
					self.loading = false;
					self.addressData = data.data;
					self.total = data.total;
					self.current = 1;
				}).catch(err => {
					self.loading = false;
					self.$message.error(err.response.data.message)
				})
			},

			// 编辑数据
			onAddressInfo(row) {
				let self = this;
				self.edit_model = true;
				localStorage.setItem('add_address_id', row)
				self.form.id = row;
				self.drawer_form = true;
				self.tabActive = "1";
				API.getIdAddress(row).then(res => {
					let data = res.data.data;
					self.form = {
						id: row ? row : '',
						project_id: data.project_id,
						aip_id: data.aip_id,
						type: data.type,
						area_id: data.area_id,
						contact: data.contact,
						address: data.address,
						lng: data.lng,
						lat: data.lat,
						bind: '1',
						notify_repair: data.notify_repair
					};
					localStorage.setItem('notify_repair', data.notify_repair)
				});
			},
			onAddressCode(row) {
				let self = this;
				self.edit_model = true;
				localStorage.setItem('add_address_id', row)
				self.form.id = row;
				self.drawer_form = true;
				self.tabActive = "2";
				API.getIdAddressInfo(row).then(res => {
					let data = res.data.data;
					self.address_code_form = { // 地址编码
						address_id: row ? row : '',
						info: data.info ? data.info : [],
					};
				});
			},
			onAddressFaceGroup(row) {
				let self = this;
				self.edit_model = true;
				localStorage.setItem('add_address_id', row)
				self.form.id = row;
				self.drawer_form = true;
				self.tabActive = "3";
				API.getIdAddressGroups(row).then(res => {
					let data = res.data.data;
					self.face_group_form = { // 人脸组
						address_id: row,
						groups: data,
					};
				});
			},
			onAddressStation(row) {
				let self = this;
				self.edit_model = true;
				localStorage.setItem('add_address_id', row)
				self.form.id = row;
				self.drawer_form = true;
				self.tabActive = "4";
				API.getIdAddressStations(row).then(res => {
					let data = res.data.data;
					self.station_form = { // 人脸组
						address_id: row,
						stations: data,
					};
				});
			},
			onAddressMaintenance(row) {
				let self = this;
				self.edit_model = true;
				localStorage.setItem('add_address_id', row)
				self.form.notify_repair = "1";
				self.form.id = row;
				self.tabActive = "5";
				self.drawer_form = true;
				API.getIdAddressRepairer(row).then(res => {
					let data = res.data.data;
					self.new_repairers = data ? data : [];
					for (let i = 0; i < self.new_repairers.length; i++) {
						self.maintenance_form.repairers.push(self.new_repairers[i].id);
					}
					self.maintenance_form.address_id = row;
				});
			},

			// 确定删除数据
			submitDeleteData(val) {
				let self = this;
				API.delAddress(val).then(res => {
					console.log(res)
					self.getData();
					self.delSuccess();
				}).catch(err => {
					self.$message.error(err.response.data.message)
				})
			},
			// 表单=========================================================
			// 切换步骤条
			tabActiveChange() {
				let self = this;
				if (!self.form.id && self.tabActive !== "1") {
					self.$message.error("请先提交地址信息");
					return false;
				}
				if (self.form.notify_repair == 2 && self.tabActive == "5") {
					self.$message.error("请在填写地址信息的那栏选择通知维护人员");
					return false;
				}
				switch (self.tabActive) {
					case "1":
						self.form = {
							id: localStorage.getItem('add_address_id') ? localStorage.getItem('add_address_id') : '',
							project_id: '',
							aip_id: '',
							type: '',
							area_id: '0',
							contact: '',
							address: '',
							lng: '',
							lat: '',
							bind: '1',
							notify_repair: localStorage.getItem('notify_repair') ? localStorage.getItem(
								'notify_repair') : 2,
						};
						if (self.edit_model) {
							self.onAddressInfo(self.form.id)
						}
						break;
					case "2":
						self.address_code_form = { // 地址编码
							address_id: localStorage.getItem('add_address_id') ? localStorage.getItem(
								'add_address_id') : '',
							info: [],
						};
						if (self.edit_model) {
							self.onAddressCode(self.form.id)
						}
						break;
					case "3":
						self.face_group_form = { // 人脸组
							address_id: localStorage.getItem('add_address_id') ? localStorage.getItem(
								'add_address_id') : '',
							groups: [],
						};
						if (self.edit_model) {
							self.onAddressFaceGroup(self.form.id)
						}
						break;
					case "4":
						self.station_form = { // 辖区
							address_id: localStorage.getItem('add_address_id') ? localStorage.getItem(
								'add_address_id') : '',
							stations: [],
						};
						if (self.edit_model) {
							self.onAddressStation(self.form.id)
						}

						break;
					case "5":
						self.maintenance_form = { // 维护人员
							address_id: localStorage.getItem('add_address_id') ? localStorage.getItem(
								'add_address_id') : '',
							repairers: []
						};
						if (self.edit_model) {
							self.onAddressMaintenance(self.form.id)
						}
						break;
				}
			},

			// 项目赋值
			getProjectId(data) {
				let self = this;
				self.form.project_id = data.child_project_id;
			},
			// 赋值AIPID
			getBaiduAipId(data) {
				let self = this;
				self.form.aip_id = data.child_aip_id;
			},

			maintenanceChange() {
				let self = this;
				self.maintenance_form.repairers = [];
			},
			getMaintenance(data) {
				let self = this;
				self.maintenance_form.repairers = [];
				self.new_repairers = data.new_maintenance;
				for (let i = 0; i < self.new_repairers.length; i++) {
					if (!self.maintenance_form.repairers.includes(self.new_repairers[i].id)) { //includes 检测数组是否有某个值
						self.maintenance_form.repairers.push(self.new_repairers[i].id);
					}
				}
			},
			// 获取编码的地址值
			getOrderCode(data) {
				let self = this;
				self.order_value = data.data;
			},
			// 获取地址类型
			getAddressType() {
				let self = this;
				API.addressType().then(res => {
					let data = res.data;
					self.$notify({
						message: '获取地址类型成功'
					});
					self.type_list = data.data;
				}).catch(err => {
					self.$message.error(err.response.data.message)
				})
			},
			// 获取地区id
			getAreaId(data) {
				let self = this;
				self.form.area_id = data.area_id;
			},
			// 地图
			getLoc(mapData) {
				let self = this;
				console.log(mapData)
				self.form.lng = mapData.latlng.lng;
				self.form.lat = mapData.latlng.lat;
				self.on_map = false;
			},
			// 添加人脸分组名称
			addFace() {
				let self = this;
				self.face_group_form.groups.push({})
			},
			delFace() {
				let self = this;
				self.face_group_form.groups.pop({})
			},

			// 获取辖区
			getStationId(data) {
				let self = this;
				self.station_form.stations = data.station_id;
			},

			// 提交表单
			getNewForm() {
				let self = this;
				self.submitSuccess();
				switch (self.tabActive) {
					case "1":
						self.form_loading = true;

						API.address(self.form).then(res => {
							localStorage.setItem('add_address_id', res.data.data.id)
							self.form.id = localStorage.getItem('add_address_id')
							localStorage.setItem('notify_repair', res.data.data.notify_repair)
							self.form.notify_repair = localStorage.getItem('notify_repair')
							self.submitSuccess();
							self.form_loading = false;
							// self.tabActive = "2";
							// self.tabActiveChange();
							// self.drawer_form = false;
							// self.initForm();
							// self.getData();
						}).catch(err => {
							self.form_loading = false;
							self.$message.error(err.response.data.message);
						});
						break;
					case "2":
						// 获取编码组件的值
						self.$refs.childCode.getCode();
						self.address_code_form.info = new Array();
						self.address_code_form.info['sbszjlx'] = self.order_value.sbszjlx;
						self.address_code_form.info['sbszsqc'] = self.order_value.sbszsqc;
						self.address_code_form.info['sbszjwq'] = self.order_value.sbszjwq;

						self.address_code_form.info['sbszjzw'] = self.order_value.sbszjzw;
						self.address_code_form.info['sbszfw'] = self.order_value.sbszfw;
						self.address_code_form.info['sbszdy'] = self.order_value.sbszdy;

						self.address_code_form.info['sbszwzsm'] = self.order_value.sbszwzsm;
						self.address_code_form.info['glsxjbm'] = self.order_value.glsxjbm;
						self.address_code_form.info['sbgldwmc'] = self.order_value.sbgldwmc;

						self.address_code_form.info['bdcqzsbh'] = self.order_value.bdcqzsbh;
						self.address_code_form.info['fwlbdm'] = self.order_value.fwlbdm;
						self.address_code_form.info['fwytdm'] = self.order_value.fwytdm;

						self.address_code_form.info['fwcqxzdm'] = self.order_value.fwcqxzdm;
						self.address_code_form.info['cqr_xm'] = self.order_value.cqr_xm;
						self.address_code_form.info['cqr_gjhdqdm'] = self.order_value.cqr_gjhdqdm;

						self.address_code_form.info['cqr_cyzjdm'] = self.order_value.cqr_cyzjdm;
						self.address_code_form.info['cqr_zjhm'] = self.order_value.cqr_zjhm;
						self.address_code_form.info['cqr_lxdh'] = self.order_value.cqr_lxdh;

						self.address_code_form.info['fwjs'] = self.order_value.fwjs;
						self.address_code_form.info['fwmj'] = self.order_value.fwmj;
						self.address_code_form.info['cqr_wwx'] = self.order_value.cqr_wwx;
						self.address_code_form.info['cqr_wwm'] = self.order_value.cqr_wwm;
						console.log(self.address_code_form);

						self.form_loading = true;
						API.addressCode(self.address_code_form).then(res => {
							console.log(res)
							self.submitSuccess();
							self.form_loading = false;
							// self.tabActive = "3";
							// self.tabActiveChange();
						}).catch(err => {
							self.form_loading = false;
							self.$message.error(err.response.data.message);
						});
						break;
					case "3":
						self.form_loading = true;
						console.log(self.face_group_form);
						API.postAddressGroups(self.face_group_form).then(res => {
							console.log(res)
							self.submitSuccess();
							self.form_loading = false;
							// self.tabActive = "4";
							// self.tabActiveChange();
						}).catch(err => {
							self.form_loading = false;
							self.$message.error(err.response.data.message);
						});
						break;
					case "4":
						self.form_loading = true;
						console.log(self.station_form);
						API.addressStations(self.station_form).then(res => {
							console.log(res)
							self.submitSuccess();
							self.form_loading = false;
							// self.form.notify_repair == "1" ? self.tabActive = "5" : self.tabActive = "1";
							// self.tabActiveChange();
						}).catch(err => {
							self.form_loading = false;
							self.$message.error(err.response.data.message);
						});
						break;
					case "5":
						console.log(self.maintenance_form);
						self.form_loading = true;
						// self.tabActiveChange();
						API.addressRepairers(self.maintenance_form).then(res => {
							console.log(res)
							self.submitSuccess();
							self.form_loading = false;
						}).catch(err => {
							self.form_loading = false;
							self.$message.error(err.response.data.message);
						});
						break;
				}
			},

			// 房间管理
			onRoomManage(row) {
				localStorage.setItem('address_id', row.id);
				localStorage.setItem('address_name', row.address);
				this.$router.replace({
					path: '/room',
					query: {
						id: row.id
					}
				});
			},
			// 地址信息服务详情
			onInfoDetail(row) {
				localStorage.setItem('address_id', row.id);
				localStorage.setItem('address_name', row.address);
				this.$router.replace({
					path: '/service-detail',
					query: {
						id: row.id
					}
				});
			},
			// 初始表单
			initAddressInfo(formName) {
				let self = this;
				self.$refs[formName].resetFields();
				self.form = {
					id: localStorage.getItem('add_address_id') ? localStorage.getItem(
						'add_address_id') : '',
					project_id: '',
					aip_id: '',
					type: '',
					area_id: '0',
					contact: '',
					address: '',
					lng: '',
					lat: '',
					bind: '1',
					notify_repair: 2
				};
			},
			initAddressCode(formName) {
				let self = this;
				self.$refs[formName].resetFields();
				self.address_code_form = { // 地址编码
					info: [],
				};
				self.address_code_form.address_id = localStorage.getItem('add_address_id') ? localStorage
					.getItem(
						'add_address_id') : '';
				self.$refs.childCode.cannelCode();
			},
			initAddressFaceGroup(formName) {
				let self = this;
				self.$refs[formName].resetFields();
				self.face_group_form = { // 人脸组
					groups: [],
				};
				self.face_group_form.address_id = localStorage.getItem('add_address_id') ? localStorage
					.getItem('add_address_id') : '';
			},
			initAddressStation(formName) {
				let self = this;
				self.$refs[formName].resetFields();
				self.station_form = { // 辖区
					stations: [],
				};
				self.select_all_station = false;
				self.station_form.address_id = localStorage.getItem('add_address_id') ? localStorage
					.getItem(
						'add_address_id') : ''
			},
			initAddressMaintenance(formName) {
				let self = this;
				self.$refs[formName].resetFields();
				self.maintenance_form = { // 维护人员
					repairers: []
				};
				self.maintenance_form.address_id = localStorage.getItem('add_address_id') ? localStorage
					.getItem(
						'add_address_id') : '';
				self.$refs.refMaintenanceComponent.delAll();
			},
			initForm() {
				let self = this;
				self.edit_model = false;
				localStorage.removeItem('add_address_id');
				localStorage.removeItem('notify_repair');
				self.tabActive = "1";
				self.form = {
					id: localStorage.getItem('add_address_id') ? localStorage.getItem('add_address_id') : '',
					project_id: '',
					aip_id: '',
					type: '',
					area_id: '0',
					contact: '',
					address: '',
					lng: '',
					lat: '',
					bind: '1',
					notify_repair: 2
				};
				self.address_code_form = { // 地址编码
					address_id: '',
					info: [],
				};
				self.face_group_form = { // 人脸组
					address_id: '',
					groups: [],
				};
				self.station_form = { // 辖区
					address_id: '',
					stations: [],
				};
				self.maintenance_form = { // 维护人员
					address_id: '',
					repairers: []
				};
				self.select_all_station = false;
				if (self.tabActive == "2") {
					self.$refs.childCode.cannelCode();
				}
				if (self.tabActive == "5") {
					self.$refs.refMaintenanceComponent.delAll();
				}
			},
		},
		beforeUnmount() {
			localStorage.removeItem('add_address_id');
			localStorage.removeItem('notify_repair');
		}
	}
</script>

<style scoped lang="scss">

</style>
